load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")

oncall("secure_pipes")

cpp_library(
    name = "libaegis",
    srcs = [
        "libaegis/AEGISCipher.cpp",
    ],
    headers = [
        "libaegis/LibAEGIS.h",
    ],
    deps = [
        "//fizz/crypto/aead:cryptoutil",
        "//folly/lang:checked_math",
    ] + select({
        "DEFAULT": [
            "fbsource//third-party/libaegis:aegis",
        ],
        # @fb-only: "ovr_config//toolchain/fb:arista": [], 
    }),
    exported_deps = [
        "//fizz:config",
        "//fizz/crypto:crypto",
        "//fizz/crypto/aead:aead",
    ],
)

cpp_library(
    name = "liboqs",
    srcs = [
        "liboqs/OQSKeyExchange.cpp",
    ],
    headers = [
        "liboqs/LibOQS.h",
        "liboqs/OQSKeyExchange.h",
    ],
    exported_deps = [
        "fbsource//third-party/liboqs:oqs",
        "//fizz:config",
        "//fizz/crypto:crypto",
        "//fizz/crypto/exchange:key_exchange",
        "//folly:memory",
    ],
)

cpp_library(
    name = "openssl",
    srcs = [
        "openssl/certificate/CertUtils.cpp",
        "openssl/crypto/OpenSSLKeyUtils.cpp",
        "openssl/crypto/Sha.cpp",
        "openssl/crypto/aead/OpenSSLEVPCipher.cpp",
        "openssl/crypto/exchange/OpenSSLKeyExchange.cpp",
        "openssl/crypto/signature/Signature.cpp",
    ],
    headers = [
        "openssl/Hasher.h",
        "openssl/OpenSSL.h",
        "openssl/Properties.h",
        "openssl/certificate/CertUtils.h",
        "openssl/certificate/CertUtils-inl.h",
        "openssl/certificate/OpenSSLPeerCertImpl.h",
        "openssl/certificate/OpenSSLPeerCertImpl-inl.h",
        "openssl/certificate/OpenSSLSelfCertImpl.h",
        "openssl/certificate/OpenSSLSelfCertImpl-inl.h",
        "openssl/crypto/ECCurve.h",
        "openssl/crypto/OpenSSL.h",
        "openssl/crypto/OpenSSLKeyUtils.h",
        "openssl/crypto/Sha.h",
        "openssl/crypto/aead/OpenSSLEVPCipher.h",
        "openssl/crypto/aead/OpenSSLEVPCipher-inl.h",
        "openssl/crypto/exchange/OpenSSLKeyExchange.h",
        "openssl/crypto/signature/Signature.h",
        "openssl/crypto/signature/Signature-inl.h",
    ],
    deps = [
        "//fizz/crypto/aead:cryptoutil",
        "//folly/lang:checked_math",
    ],
    exported_deps = [
        "//fizz:config",
        "//fizz/compression:certificate_compressor",
        "//fizz/crypto:crypto",
        "//fizz/crypto:hasher",
        "//fizz/crypto:hkdf",
        "//fizz/crypto/aead:aead",
        "//fizz/crypto/aead:iobuf",
        "//fizz/crypto/exchange:key_exchange",
        "//fizz/protocol:certificate",
        "//fizz/record:record",
        "//folly:conv",
        "//folly:memory",
        "//folly:range",
        "//folly:string",
        "//folly/io:iobuf",
        "//folly/io/async/ssl:openssl_transport_certificate",
        "//folly/lang:assume",
        "//folly/lang:bits",
        "//folly/portability:openssl",
        "//folly/ssl:openssl_cert_utils",
        "//folly/ssl:openssl_hash",
        "//folly/ssl:openssl_ptr_types",
    ],
    exported_external_deps = [
        "glog",
        ("openssl", None, "crypto"),
    ],
)

cpp_library(
    name = "libsodium",
    srcs = [
        "libsodium/crypto/exchange/X25519.cpp",
    ],
    headers = [
        "libsodium/LibSodium.h",
        "libsodium/crypto/exchange/X25519.h",
    ],
    deps = [
        "//folly:conv",
    ],
    exported_deps = [
        "//fizz/crypto:crypto",
        "//fizz/crypto/exchange:key_exchange",
        "//folly:optional",
        "//folly:range",
        "//folly/io:iobuf",
    ],
    exported_external_deps = [
        ("libsodium", None, "sodium"),
    ],
)
